<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <title>修改车辆信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="resources/layui/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="resources/layui/css/public.css" media="all" />
</head>
<body class="childrenBody">
<form class="layui-form" style="width:100%;" id="dataFrm">
    <input id="id" name="id" type="hidden">
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">车牌号码:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input car_no" name="car_no" lay-verify="required" placeholder="请输入车牌号码">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">车辆品牌:</label>
        <div class="layui-input-block">
            <select id="car_brandText" name="car_brand.id" class="car_brandText" lay-filter="car_brandText">
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">车辆型号:</label>
        <div class="layui-input-block">
            <select id="car_modelText" name="car_model.id" class="unit_typeText" lay-filter="car_modelText">
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">车辆颜色:</label>
        <div class="layui-input-block">
            <select id="car_colorText" name="car_color.id" class="car_colorText" lay-filter="car_colorText">
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">载重:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input car_load" name="car_load" lay-verify="required" placeholder="请输入载重">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">座位数:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input car_seats" name="car_seats" lay-verify="required" placeholder="请输入座位数">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">油耗:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input oil_wear" name="oil_wear" lay-verify="required" placeholder="请输入油耗">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">初始里程:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input init_mil" name="init_mil" lay-verify="required" placeholder="请输入初始里程">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">保养里程:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input maintain_mil" name="maintain_mil" lay-verify="required" placeholder="请输入保养里程">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">保养周期:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input maintain_period" name="maintain_period" lay-verify="required" placeholder="请输入保养周期">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">发动机号:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input engine_num" name="engine_num" lay-verify="required" placeholder="请输入发动机号">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">车架号:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input frame_num" name="frame_num" lay-verify="required" placeholder="请输入车架号">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">供应商:</label>
        <div class="layui-input-block">
            <select id="sup_idText" name="sup_id.id" class="sup_idText" lay-filter="sup_idText">
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">购买价格:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input purchase_price" name="purchase_price" lay-verify="required" placeholder="请输入购买价格">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">购买日期:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input purchase_date" name="purchase_date" lay-verify="required" placeholder="请输入购买日期">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">部门:</label>
        <div class="layui-input-block">
            <select id="dept_idText" name="dept_id.id" class="dept_idText" lay-filter="dept_idText">
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">状态:</label>
        <div class="layui-input-block">
            <select id="car_stateText" name="car_state.id" class="car_stateText" lay-filter="car_stateText">
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">备注:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input remarks" name="remarks" lay-verify="required" >
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block isdisable">
            <input type="radio" name="able" value="1" title="启用">
            <input type="radio" name="able" value="0" title="禁用">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="saveCar">保存</button>
            <button type="reset" class="layui-btn layui-btn-sm layui-btn-primary">取消</button>
        </div>
    </div>
</form>
<script type="text/javascript" src="resources/layui/layui/layui.js"></script>
<script th:inline="none">
    layui.use(['form','layer','laydate','table','laytpl','upload'],function() {
        var form = layui.form
        layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laydate = layui.laydate,
            laytpl = layui.laytpl,
            table = layui.table,
            upload=layui.upload;

        form.render('select');

        form.on('select(car_brandText)', function(data){
            $("#car_modelText").empty();
            var car_brandText=$('#car_brandText').find("option:selected").val();
            $.ajax({
                url:'/car/carmodel/'+car_brandText,
                success:function (data) {
                    carmodel = "<option value=''>------------请选择------------</option>"
                    for (i = 0; i < data.length; i++) {
                        carmodel += ("<option value='" + data[i].id + "'>" + data[i].name + "</option>")
                    }
                    $("#car_modelText").append(carmodel);
                    form.render('select');
                }
            });
        });

        form.on("submit(saveCar)",function (data) {
            var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
            //实际使用时的提交数据
            var params=$("#dataFrm").serialize();
            console.log(params);
            $.post("editcars.do",params,function (res) {
                console.log(res.code);
                if(res.code==3008){
                    top.layer.close(index);
                    top.layer.msg(res.msg);
                    var index1=parent.layer.getFrameIndex(window.name)
                    parent.layer.close(index1);
                    parent.location.reload();
                }else if(res.code=-3008){
                    layer.msg(res.msg);
                }
            },"json");
            return false;
        });
    });
</script>
</body>
</html>